<?php defined('IN_IA') or exit('Access Denied');?><?php (!empty($this) && $this instanceof WeModuleSite) ? (include $this->template('common/header', TEMPLATE_INCLUDEPATH)) : (include template('common/header', TEMPLATE_INCLUDEPATH));?>
<?php (!empty($this) && $this instanceof WeModuleSite) ? (include $this->template('common', TEMPLATE_INCLUDEPATH)) : (include template('common', TEMPLATE_INCLUDEPATH));?>
<div class="box">
    <div class="bg">
        <div style="margin:43% 15px 0 15px;">
            <?php  if(empty($got)) { ?>
                <?php  if($activity['type'] == 'direct') { ?>
                    <h5 class="text-center">您收到一个大红包, 马上打开看看吧</h5>
                <?php  } else { ?>
                    <?php  if($help['already'] > 0) { ?>
                    <div class="progress">
                        <div class="progress-bar progress-bar-warning  progress-bar-striped active" role="progressbar" aria-valuenow="<?php  echo $help['already'];?>" aria-valuemin="0" aria-valuemax="<?php  echo $help['total'];?>" style="width: <?php  echo $help['already']*100/$help['total']?>%">
                        </div>
                    </div>
                    <?php  } ?>
                    <?php  if($help['ok']) { ?>
                    <h5 class="text-center" style="margin-top:20px">
                        辛苦向好友们讨红包. 总算讨到了一个大红包。 
                    </h5>
                    <?php  } else { ?>
                    <h5 class="text-center" style="margin-top:20px">
                        发红包啦, 现在就去向好友讨红包. 还需要 <mark><?php  echo $help['total'] - $help['already']?></mark> 个好友赏脸, 就能领到一个大红包
                    </h5>
                    <?php  } ?>
                <?php  } ?>
            <?php  } else { ?>
                <?php  if($got['status'] == 'success') { ?>
                    <h5 class="text-center">您已经成功领取大红包, 请到好友列表里查收红包</h5>
                <?php  } else { ?>
                    <h4 class="text-center"style=" line-height:23px"><strong>红包还没有打开, 您可以重新领取</strong></h4>
                    <h5 class="text-center" style="margin-top:-8px; line-height:17px">我们的红包只有在每天 08:00 - 23:59 才发放哦. 如果没有领取成功, 可以避开这个时间段重新领取. 或者联系我们</h5>
                <?php  } ?>
            <?php  } ?>
        </div>
    </div>
    <div class="btns container">
        <div class="form-group">
            <?php  if(empty($got)) { ?>
                <?php  if($activity['type'] == 'direct') { ?>
				<!-- <p style='color:yellow; float:left;margin-left:25px;'>手机号：</p><input type="tel" maxlength="11" id="user-phone" name="mobile" autocomplete="off" placeholder=""  value="" style="margin:0 auto;margin-bottom:10px;display:block;float:left"> -->
				<p style='color:yellow; float:left;margin-left:25px;margin-top:5px;'>验证码：</p><input type="tel" maxlength="9" id="user-yzm" name="user-yzm" autocomplete="off" placeholder=""  value="" style="margin:0 auto;margin-bottom:10px;display:block;float:left;height:40px;"><IMG style="clear:both;margin:5px 0 5px 50px" id=nyzm align=absMiddle src='<?php  echo $this->createMobileUrl("img")?>' onClick="reloadcode();"><a href="javascrop:void(0)" onClick="reloadcode();">点击图片刷新</a>
                    <button class="btn btn-warning btn-block" onclick="doSend();">马上打开红包</button>
                <?php  } else { ?>
                    <?php  if($help['ok']) { ?>
					<!-- <p style='color:yellow;float:left;margin-left:25px;'>手机号：</p><input type="tel" maxlength="11" id="user-phone" name="mobile" autocomplete="off" placeholder=""  value="" style="margin:0 auto;margin-bottom:10px;display:block;float:left"> -->
					<p style='color:yellow; float:left;margin-left:25px;margin-top:5px;'>验证码：</p><input type="tel" maxlength="9" id="user-yzm" name="user-yzm" autocomplete="off" placeholder=""  value="" style="margin:0 auto;margin-bottom:10px;display:block;float:left;height:40px;"><IMG style="clear:both;display:block;margin:5px auto;" id=nyzm align=absMiddle src='<?php  echo $this->createMobileUrl("img")?>' onClick="reloadcode();">
                        <button class="btn btn-warning btn-block" onclick="doSend();">马上打开红包</button>
                    <?php  } else { ?>
                        <button class="btn btn-warning btn-block" onclick="shareDialog();">向好友讨红包</button>
                    <?php  } ?>
                <?php  } ?>
            <?php  } else { ?>
                <?php  if($got['status'] == 'success') { ?>
                    <button class="btn btn-warning btn-block" disabled>已经领取过红包了</button>
                <?php  } else { ?>
				<p style='color:yellow; float:left;margin-left:25px;margin-top:5px;'>验证码：</p><input type="tel" maxlength="9" id="user-yzm" name="user-yzm" autocomplete="off" placeholder=""  value="" style="margin:0 auto;margin-bottom:10px;display:block;float:left;height:40px;"><IMG style="clear:both;display:block;margin:5px auto;" id=nyzm align=absMiddle src='<?php  echo $this->createMobileUrl("img")?>' onClick="reloadcode();">
                    <button class="btn btn-warning btn-block" onclick="doSend();">重新领取红包</button>
                <?php  } ?>
            <?php  } ?>
        </div>
        <?php  if($activity['type'] == 'shared' && $help['already'] > 0) { ?>
        <div class="form-group">
            <button class="btn btn-warning btn-block" onclick="myDialog()">查看收到我讨红包的好友</button>
        </div>
        <?php  } ?>
        <div class="form-group">
            <button class="btn btn-link btn-block text-right" onclick="rulesDialog();"style="color:#f3e17b">查看活动说明</button>
             <p style="color:#fff; font-size:14px" class="text-center">&nbsp;&nbsp;</p>

        </div> 
        <script>
            function doSend() {
                require(['jquery', 'util'], function($, u){
					var tel = $("#user-phone").val();
					var yzm = $("#user-yzm").val();
					if(yzm==""){
						u.message('请输入验证码');
						return false;
					}
//					if(tel==""){
//						u.message('请输入手机号码');
//						return false;
//					}else if(tel.length!=11){
//						u.message('请输入手机号码');
//						return false;	
//					}else {
//						
//						
//						 var myreg = /^1\d{10}$/;
//							if(!myreg.test(tel)) {
//					
//							   u.message('请输入手机号码');
//								return false;
//							}
//						
//						
//					}
                    $.post('<?php  echo $this->createMobileUrl("send")?>',{tel:tel,yzm:yzm}).success(function(dat){
                        if(dat == 'success') {
                            location.reload();
                        } else {
                            u.message(dat);
                        }
                    });
                });
            }
			function reloadcode(){
				 location.reload();
			}
            function myDialog() {
                require(['jquery'], function($){
                    $('.rules-dialog .dialog-content').removeClass('fadeOutDownBig').addClass('fadeInUpBig');
                    $.post('<?php  echo $this->createMobileUrl("my")?>').success(function(dat){
                        $('.rules-dialog .dialog-content .content').html(dat);
                        $('.rules-dialog').show();
                    });
                })
            }
        </script>
    </div>

